#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main()
{
    int monthinfo[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    int year, month, day;
    scanf("%d %d %d", &year, &month, &day);

    if (year % 4 == 0 && year % 100!= 0 || year % 400 == 0)
        monthinfo[1]++;

    int dae = 0;
    for (int i = 0; i < month - 1; i++)
    {
        dae += monthinfo[i];
    }
    dae += day;

    printf("%d", dae);


    return 0;
}